﻿using System;
using System.Collections;


using mborn.Model;
using mborn.DAL;

namespace mborn.BLL
{
    public class UserClassBLL
    {
        public void AddUserClass(UserClass userClass) 
        {
            UserClassDAL dal = new UserClassDAL();
            dal.AddUserClass(userClass);
        }

        public void DelUserClass(UserClass userClass)
        {
            UserClassDAL dal = new UserClassDAL();
            dal.DelUserClass(userClass);
        }

        public int GetCntByID(int ID) 
        {
            string strHQL;
            IList aList;

            UserClass model = new UserClass();
            UserClassDAL dal = new UserClassDAL();

            strHQL = "from mborn.Model.UserClass as userClass where ID=" + Convert.ToString(ID);

            aList = dal.GetUserClass(strHQL);

            if (aList.Count > 0) 
                model = (UserClass)aList[0];

            return model.ClassCnt;

        }

        public void UpdateUserClass(UserClass userClass)
        {
            UserClassDAL dal = new UserClassDAL();
            dal.UpdateUserClass(userClass, userClass.ID);
        }

        /// <summary>
        /// 根据用户的id获取该用户所有的自定义blog文章分类
        /// </summary>
        /// <param name="userID">用户的id</param>
        /// <returns>分类的IList</returns>
        public IList GetUserClassByUserID(int userID)
        {
            string strHQL;
            UserClassDAL dal = new UserClassDAL();

            strHQL = "from mborn.Model.UserClass as userClass where UserID = " + Convert.ToString(userID);

            return dal.GetUserClass(strHQL);
        }
    }
}
